﻿@model CW_Menu
@{
    ViewBag.Title = "ArticleCreate";
    List<CW_Menu> menuList = ViewBag.menuList;
    List<CW_Tag> tagList = ViewBag.tagList;
}

<h2>ArticleCreate</h2>
<div>
    @Html.ActionLink("Back to List", "ArticleList", null, new { Class = "btn btn-default" })
</div>
<hr />
@using (Html.BeginForm("ArticleCreate", "Admin", FormMethod.Post, new { id = "form1", Class = "from", onsubmit = "return checkInput();", enctype = "multipart/form-data" }))
{
    <div class="form-group">
        <label>标题</label>
        <input type="text" class="form-control" name="Title" data-rule-required='true' data-msg-required="请输入标题">
    </div>
    <div class="form-group">
        <label>作者</label>
        <input type="text" class="form-control" name="Author" data-rule-required='true' data-msg-required="请输入作者">
    </div>
    <div class="form-group">
        <label>logo</label>
        <input type="file" name="thumbnail" />
    </div>
    <div class="form-group">
        <label>简介</label>
        <textarea class="form-control" rows="5" name="Abstract" data-rule-required='true' data-msg-required="请输入简介"></textarea>
    </div>
    <div class="form-group">
        <label>内容</label>
        <textarea id="editor" rows="5" name="Content" data-rule-required='true' data-msg-required="请输入内容"></textarea>
    </div>
    @*<div class="form-group">
        <label>所属菜单</label>
        <div class="radio">
            <label class="radio-inline">
                <input type="radio" name="MenuId" value="" />没有
            </label>

            @foreach (CW_Menu p in menuList)
            {
                <label class="radio-inline">
                    <input type="radio" name="MenuId" value="@p.MenuId" />@p.MenuName
                </label>
            }
        </div>
    </div>*@
    <div class="form-group">
        <label>标签</label>
        <div class="checkbox">
            @foreach (CW_Tag p in tagList)
            {
                <label class="checkbox-inline">
                    <input type="checkbox" name="TagId" value="@p.TagId" />@p.TagName
                </label>
            }
        </div>
    </div>
    <div class="form-group">
        <div class="checkbox">
            <label>
                <input type="checkbox" name="IsShow" value="true">
                发布
            </label>
        </div>
    </div>
    <button type="submit" class="btn btn-default">Submit</button>
}

@section Scripts {
    <script src="~/scripts/jquery.validate.min.js"></script>

    <script src="~/UEditor/ueditor.config.js"></script>
    <script src="~/UEditor/ueditor.all.min.js"></script>
    <script src="~/UEditor/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript">
        //实例化编辑器
        //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
        var ue = UE.getEditor('editor');
    </script>
    <script>
        $(function () {
            validateCN();
        })
        function validateCN() {
            $("form").validate({
                errorClass: "text-danger text-sm",
                errorPlacement: function (error, element) {
                    element.after(error);
                }
            });
        }
        function checkInput() {
            return $("#form1").valid();
        }
    </script>
}
